const app = getApp()
Page({
  data: {
    recordList: [],
    scrollHeight: 0,
    deviceID: null,
    deviceName: null,
  },
  toPage(e) {
    app.navigateTo(e.currentTarget.dataset.link)
  },
  onLoad(option) {
    if (option.id) {
      this.setData({
        deviceID: option.id
      })
      this.getHistoryList()
    }
    this.setData({ recordList: this.mockData() });
  },
  getHistoryList() {
    app.axios('device', {
      op: 'ajaxGbwarrList',
      qrid: this.data.deviceID
    }).then(res => {
      if (res.code && res.lists && res.lists.length > 0) {
        res.lists.forEach(item => {
          item.dateTime = app.dateFormatter(item.addtime, true)
          item.info = item.title
        })
        this.setData({
          recordList: res.lists,
          deviceName: res.lists[0].rname
        })
      }
    })
  },
})